import axios from "axios";
import {useStore} from "../pinia/index.js";


// 配置axios 拦截器
axios.interceptors.request.use(
    (config) => {
        //携带token 令牌
        const store=useStore()
        config.headers.Lctoken = store.token
        // config.headers.lcuid = store.user.id
        return config;
    }, (error) => {
        return Promise.reject(error);
    }
);

const baseurl="http://localhost:8081/api/"// 路径前缀

const get = (url, params) => {  // 封装get
    return axios.get(baseurl+url,{params}).then(res => res.data);
};

// post请求
const post = (url, params) => {  // 封装post
    return axios.post(baseurl+url,params).then(res => res.data);
};
export {
    get,
    post
}
